export default {
    ADD_TO_CART(state, product) {
      const existingItem = state.cartItems.find(item => item.id === product.id)
      if (existingItem) {
        existingItem.quantity += product.quantity
      } else {
        state.cartItems.push(product)
      }
    },
    
    REMOVE_FROM_CART(state, productId) {
      state.cartItems = state.cartItems.filter(item => item.id !== productId)
    },
    
    UPDATE_QUANTITY(state, { productId, quantity }) {
      const item = state.cartItems.find(item => item.id === productId)
      if (item) {
        item.quantity = quantity
      }
    }
  }